package com.whx.yimixian.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by wencai2015 on 2016/10/18.
 */

public abstract class BaseFragment extends Fragment {

    private Context context;
    private Unbinder bind;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context=context;
    }


    public Context getFActivity(){
        return context;
    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(getLayoutId(),null);
        bind = ButterKnife.bind(view);
        initView();

        return view;
    }



    public abstract void   initView();
    public abstract  int getLayoutId();

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (bind != null){
            bind.unbind();
        }
    }
}
